/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.dao;

import java.util.List;
import model.pojo.Agents;
import model.util.HibernateUtil;
import org.hibernate.*;


/**
 *
 * @author tho
 */
public class AgentsDAO {
    
    public static List<Agents> getLS(){
        List<Agents> lis = null;
       
        try {
            Session session = HibernateUtil.getSessionFactory().openSession();
            String ag="from Agents";
            Query query= session.createQuery(ag);
            lis=query.list();            
            session.close();
//            SessionFactory session = HibernateUtil.getSessionFactory();
//            session.getCurrentSession().beginTransaction();
//            lis= session.getCurrentSession().createCriteria(Agents.class).list();
        } catch (Exception e) {
            return null;
        }
        return lis;
    }
//    private final SessionFactory session= HibernateUtil.getSessionFactory();
//    
//    public  List<Agents> getLS(){
//        List<Agents> lis = null;
//        try {
//            session.getCurrentSession().beginTransaction();
//            lis= session.getCurrentSession().createCriteria(Agents.class).list();
//            
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return lis;
//    }
    
}
